package com.itheima.controller;

import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    //新增体检套餐
    @PostMapping("/add")
    public Result add(Integer[] checkgroupIds, @RequestBody Setmeal setmeal){
        setmealService.add(checkgroupIds, setmeal);
        return new Result(true,"新增套餐成功");

    }
    //编辑套餐

    @PostMapping("/edit")
    public Result edit(Integer[] checkGroupIds, @RequestBody Setmeal setmeal){
        setmealService.edit(checkGroupIds, setmeal);
        return new Result(true,"编辑套餐成功");
    }
    //根据id查询套餐

    @GetMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setmealService.findById(id);
        return new Result(true,"查询套餐成功",setmeal);
    }
    //   分页查询


    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return setmealService.findPage(queryPageBean);
    }
    //   图片上传
    @PostMapping("/upload")
    public Result upload(@RequestParam("imgFile") MultipartFile imgFile){
        return new Result(true,"图片上传成功",setmealService.upload(imgFile));
    }

}
